#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <string.h>

void main()
{	
	DIR *dir = opendir(".");
	DIR *dir1;
//	mkdir("AAA",0664);
//	rmdir("AAA");
//	chmod("BBB",0755);

	struct dirent *a,*b;
	struct stat buf;
	while (a = readdir(dir))
	{
		printf("%s  ",a->d_name);
		stat(a->d_name,&buf);
		printf("%d\n",S_ISDIR(buf.st_mode));

		if(S_ISDIR(buf.st_mode) == 1 && strcmp(a->d_name,"..") !=0 && strcmp(a->d_name,".") != 0)
		{			
			dir1 = opendir(a->d_name);
			printf("in %s ,there is : ",a->d_name);
			while(b = readdir(dir1))
			{
				printf("%s ,  ",b->d_name);				
			}
			printf("\n");
			closedir(dir1);
		}

	}

	closedir(dir);


}